package com.imot.controller;

import com.imot.response.Result;
import com.imot.service.FutureTrendsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * ClassName: FutureTrendsController
 * Description:
 * date: 2023/11/18 15:00
 *
 * @author imot-jiah.wang
 */
@Api(tags = "趋势预测控制器")
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/futureTrends")
public class FutureTrendsController {
    private final FutureTrendsService futureTrendsService;

    @ApiOperation("趋势分析")
    @GetMapping("/analyzeTrends")
    public Result analyzeTrends(String name){
        Result result = futureTrendsService.analyzeTrends(name);
        return result;
    }

    @ApiOperation("失效预测")
    @PostMapping("/predictFailure")
    public Result predictFailure(String name,String model){
        Result result = futureTrendsService.predictFailure(name,model);
        return result;
    }

    @ApiOperation("历史预测最上面的展示界面")
    @GetMapping("/historicalPredictions")
    public Result historicalPredictions(){
        Result result = futureTrendsService.historicalPredictions();
        return result;
    }

    @ApiOperation("展示分页查询的界面")
    @PostMapping("/getHistoryPage")
    public Result getHistoryPage(@RequestParam(required = false)LocalDateTime startTime,
                                 @RequestParam(required = false)LocalDateTime endTime,
                                 @RequestParam(required = false)String deviceName){
        Result result = futureTrendsService.getHistoryPage(startTime,endTime,deviceName);
        return result;
    }

    @ApiOperation("查看详情")
    @PostMapping("/getHistoryDetail")
    public Result getHistoryDetail(Integer id){
        Result result = futureTrendsService.getHistoryDetail(id);
        return result;
    }


}

